import { ref } from 'vue'
import {
	defineStore
} from 'pinia'

export const useNovelStore = defineStore('novel', () => {
	// #ifdef MP-WEIXIN
	/**
	 * novelManager句柄
	 */
	const novelManagerId = ref<number>(-1)


	/**
	 * 微信书籍ID
	 */
	const book_id = ref<string>('')
	// #endif

	// #ifndef MP-WEIXIN
	/**
	 * 书id
	 */
	const novel_id = ref<number>(-1)
	// #endif

	/**
	 * 章节下标
	 */
	const chapterIndex = ref<number>(-1)
	
	const pay_amount = ref<number>(0)

	return {
		// #ifdef MP-WEIXIN
		novelManagerId,
		book_id,
		// #endif

		// #ifndef MP-WEIXIN
		novel_id,
		// #endif

		chapterIndex,
		pay_amount
	}
}, {
	persist: {
		storage: {
			setItem(key, value) {
				uni.setStorageSync(key, value)
			},
			getItem(key) {
				return uni.getStorageSync(key)
			}
		}
	}
})